for _ in range(int(input())):
w = [int(i) for i in input().split()]
if sum(w) % 3 == 0:
print(0)
else:
print(1)
/*
Author : Vimal Kumar Dubey
Cf handle : code_vkd_001
--------------------------------------------------------------------------------------
Roses do not bloom hurriedly; for beauty, like any masterpiece, takes time to blossom */
#include<bits/stdc++.h>
/*-------------------------------------------------------------------------------------------------------------*/
#define loop(k,b,a) for(ll k=b;k<a;k++)
#define vl vector<ll>
#define print(s) cout<<s<<endl;
#define beg2end(count) count.begin(),count.end()
using namespace std;
#define ll long long
#define KOPIKO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define getArr ll n; cin>>n; vl arr(n); for(auto&i:arr) cin>>i;
/*-------------------------------------------------------------------------------------------------------------*/
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxpq = priority_queue<T>;
/*-----------------------------------------CODE BEGINS ->!-------------------------------------------*/
void Selmon_Bhoi() {
ll a,b,c; cin>>a>>b>>c;
cout<<((a + c - 2*b)%3==0 ? "0" : "1")<<endl;
}
int main() {
KOPIKO
#ifndef ONLINE_JUDGE
cerr << "Exectution Time : " << clock() / (double)CLOCKS_PER_SEC << "sec ";
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ll t; cin >> t; while (t--)
Selmon_Bhoi();
}
1294C - Product of Three Numbers | 749A - Bachgold Problem |
1486B - Eastern Exhibition | 1363A - Odd Selection |
131B - Opposites Attract | 490C - Hacking Cypher |
158B - Taxi | 41C - Email address |
1373D - Maximum Sum on Even Positions | 1574C - Slay the Dragon |
621A - Wet Shark and Odd and Even | 1395A - Boboniu Likes to Color Balls |
1637C - Andrew and Stones | 1334B - Middle Class |
260C - Balls and Boxes | 1554A - Cherry |
11B - Jumping Jack | 716A - Crazy Computer |
644A - Parliament of Berland | 1657C - Bracket Sequence Deletion |
1657B - XY Sequence | 1009A - Game Shopping |
1657A - Integer Moves | 230B - T-primes |
630A - Again Twenty Five | 1234D - Distinct Characters Queries |
1183A - Nearest Interesting Number | 1009E - Intercity Travelling |
1637B - MEX and Array | 224A - Parallelepiped |